<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改产品基本信息')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-baseInfo-edit" th:object="${productBaseInfo}">
            <input name="id" th:field="*{id}" type="hidden">
<!--            <div class="form-group">-->
<!--                <label class="col-sm-3 control-label is-required">商家名称：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="storeName" th:field="*{storeName}" class="form-control" type="text" required>-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">产品名称：</label>
                <div class="col-sm-8">
                    <input name="prodName" th:field="*{prodName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">产品logo：</label>
                <div class="col-sm-8">
                    <img alt="[ 产品logo ]" width="90px" height="60px"  src="" id="logoUrl_img" th:src="*{prodLogo}">
                    <input name="prodLogo" id="logoUrl" class="form-control" type="hidden" required>
                    <input id="inputImage" name="file" type="file" >
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">产品地址：</label>
                <div class="col-sm-8">
                    <input name="prodUrl" th:field="*{prodUrl}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">租机期限：</label>
                <div class="col-sm-8">
                    <input name="termInfo" th:field="*{termInfo}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">标签信息：</label>
                <div class="col-sm-8">
                    <select class="form-control" name="labelInfo" multiple>
                        <option th:each="item : ${labellist}" th:value="${item.name}" th:text="${item.name}" th:selected="${item.selected}"></option>
                    </select>

                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">申请人数：</label>
                <div class="col-sm-8">
                    <input name="applyNumber" th:field="*{applyNumber}" class="form-control" type="text" required>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "prod/baseInfo";
        $("#form-baseInfo-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-baseInfo-edit').serialize());
            }
        }

        $(document).ready(function () {
            // 单图上传
            $("#inputImage").fileinput({
                uploadUrl: ctx + 'common/upload/prodlogo',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                var rsp = data.response;
                $("#logoUrl").val(rsp.fileUrl)
                $("#logoUrl_img").attr("src", rsp.fileUrl)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
        });
    </script>
</body>
</html>